<template>
  <div v-html="message"></div>
</template>
<script>
export default {
  name: "ErrorMessage",
  props: {
    value: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {};
  },
  computed: {
    message() {
      let text = "";
      this.value.goodsList?.forEach((item) => {
        if (item.errors) {
          this.value.errors = this.value.errors
            ? this.value.errors.concat(item.errors)
            : item.errors;
        } else {
          this.value.errors = this.value.errors;
        }
      });
      this.value.errors?.forEach((ele, index) => {
        text += `${
          (index !== 0 && ele.rowNum !== this.value.errors[index - 1].rowNum) ||
          index === 0
            ? `第${ele.rowNum}行`
            : ""
        }${ele.message}${
          (index !== this.value.errors.length - 1 &&
            ele.rowNum !== this.value.errors[index + 1].rowNum) ||
          index === this.value.errors.length - 1
            ? "<br>"
            : "；"
        }`;
      });
      return text;
    }
  }
};
</script>
